import java.util.Scanner;

/**
 * @Author: XXHH
 * @CreateTime: 2024-12-12
 */
public class Demo24 {
    public static int flag;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
           // 进行读操作
            while (flag == 0){

            }
            System.out.println("t1线程结束...");
        });
        Thread t2 = new Thread(()->{
            // 进行写操作
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入flag的值:");
            flag = scanner.nextInt();
        });
        t1.start();
        t2.start();
    }
}
